package com.wing.cabinet.model.response;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.wing.cabinet.model.entity.Cabinet;
import com.wing.cabinet.model.entity.CabinetCargoLane;
import com.wing.cabinet.model.entity.CabinetCargoSpace;
import com.wing.product.model.entity.ProductType;
import com.wing.wcabinet.model.entity.WcabCellInventorySpace;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 刀柜货道VO
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class CabinetCargoLaneVO {

    /**
     * ID
     */
    private Long id;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime createTime;

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 编号
     */
    private String code;

    /**
     * 货道编号
     */
    private String laneCode;

    /**
     * 入驻企业ID
     */
    private Long settledCompanyId;

    /**
     * 刀柜ID
     */
    private Long cabinetId;

    /**
     * 产品ID
     */
    private Long productId;

    /**
     * 产品SKU
     */
    private String productSku;

    /**
     * 货道承载数量
     */
    private Integer quantity;



    /**
     * 货道当前库存数
     */
    private Integer currentStockCount;


    /**
     * 柜子编号
     */
    private String cabCode;

    /**
     * 库存数量
     */
    private Integer quantityInventory;

    /**
     * 可用数量
     */
    private Integer quantityUsable;

    /**
     * 产品sku码
     */
    private String skuCode;

    /**
     * 产品sku名称
     */
    private String skuName;

    /**
     * 货道库存状态ikistauts
     */
    private Integer spaceStauts;



    /**
     * sku 规格
     */
    private String skuSpec;

    /**
     * sku 图片
     */
    private String skuPic;

    /**
     * 产品名称
     */
    private String productName;

    /**
     * 产品类型名称
     */
    private String productTypeName;

    /**
     * 产品分类名称
     */
    private String productCategoryName;

    /**
     * 产品品牌
     */
    private String productBrandName;

    /**
     * 产品型号
     */
    private String productModelName;

    /**
     * 适配机床
     */
    private String deviceName;

    /**
     * 市场价
     */
    private BigDecimal marketPrice;
    /**
     * 库存状态
     */
    private CabinetCargoLane.StockStatus stockStatus;

    /**
     * 库存状态描述
     */
    @TableField(exist = false)
    private String stockStatusDesc;

    public String getStockStatusDesc() {
        return stockStatus == null ? null : stockStatus.getDesc();
    }

    /**
     * 状态
     */
    private CabinetCargoLane.Status status;

    /**
     * 状态描述
     */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 货道类型id
     *
     */
    private Long spaceTypeId;

    /**
     * 货道类型名称
     */
    private String spaceTypeName;

    /**
     * 货道类型编码
     */
    private String spaceTypeCode;

    /**
     * 品牌名称
     */
    private String brandName;

    private String remark;

    /**
     * 可存放量
     */
    private Integer storageCapacity;

    private Long skuId;

    private Cabinet.CabinetNature cabinetNature;


    private String skuSpecOld;


    private Integer quantityMax;

    /**
     * 最大承重
     */
    private BigDecimal maxBearing;

    /**
     * 最大体积
     */
    private BigDecimal maxVolume;


    /**
     * 权责人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long principal;

    /**
     * 入柜产品类型
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long spaceProductType;




    //    @TableField(fill = FieldFill.INSERT_UPDATE)
    private CabinetCargoLane.SpaceType spaceType;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String principalName;


    private String spaceTypeDesc;

    public String getSpaceTypeDesc(){
        if (spaceType!=null){
            return spaceType.getDesc();
        }
        return "";
    }

    private BigDecimal weightCapacity;


    private BigDecimal currentWeight;

    /**
     * 企业编码
     */
    private String enterpriseCode;


    private BigDecimal skuWeightUnit;


    private String unitName;

    private Integer currentQuantity;

    public Integer getCurrentStockCount(){
        return this.quantityInventory;
    }

    public  Integer getCurrentQuantity(){
        return this.quantityInventory;
    }

    public Integer getStorageCapacity(){
        if (this.quantityInventory!=null&&this.quantity!=null){
            return this.quantity-this.quantityInventory;
        }else if(this.quantity!=null){
            return this.quantity;
        }
        return Integer.MAX_VALUE;
    }

    public BigDecimal getWeightCapacity(){
        if (this.currentWeight!=null&&this.maxBearing!=null){
            return this.maxBearing.subtract(this.currentWeight);
        }else if(this.maxBearing!=null){
            return this.maxBearing;
        }
        return BigDecimal.valueOf(Double.MAX_VALUE);
    }

    private WcabCellInventorySpace.BusinessType businessType;


    private BigDecimal weightInventory;

    private BigDecimal weightMax;


    private String skuCodeCurrent;


    private BigDecimal baseWeight;

    private String weightUnitName;

    private BigDecimal weight;


    private ProductType.WeightUnit weightUnit;


    private String weightUnitDesc;


    public String getWeightUnitDesc(){
        if (this.weightUnit!=null){
            return this.weightUnit.getDesc();
        }
        return "";
    }

    private String businessTypeCode;

    public String getBusinessTypeCode(){
        if (this.businessType!=null){
            return this.businessType.name();
        }
        return "";
    }

    private String spaceCode;

    private String quantityUnitDesc;

    public String getQuantityUnitDesc(){
        return this.unitName;
    }


    private String businessTypeDesc;

    public String getBusinessTypeDesc(){
        if (this.businessType!=null){
            return this.businessType.getDesc();
        }
        return "";
    }

    private Boolean isDelete;

    private Integer quantityPackUnit;

    private Long packId;

    private String packName;


    private Integer quantityPack;

    private Boolean alarm;

    private String mainCabCode;
}
